<template>
  <div class="components-container" v-cloak>
    <sweet-modal ref="dialog" class="dialog" :sweetModalMaxWidth="pageWidth">
      <h3>{{title}}</h3>
      <div style="margin:10px 20px">
        <div class="layui-form-item" v-if="isAdd">
          <div class="layui-inline">
            <label class="layui-form-label">业务编号</label>
            <div class="layui-input-inline">
              <el-input v-model="regInfo.CHDREGNO" placeholder="请输入业务编号" @keyup.enter.native="getRegInfo">
                <el-button slot="append" icon="el-icon-search" @click="getRegInfo"></el-button>
              </el-input>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">逝者姓名</label>
            <div class="layui-input-inline">
              <!-- <el-input v-model="regInfo.CHDREGNAME" readonly></el-input> -->
              <!-- <el-input v-model="regInfo.CHDDEADNAME" :readonly="!isAdd"></el-input> -->
              <el-input v-model="regInfo.REGNAME" :readonly="!isAdd"></el-input>
            </div>
            <label class="layui-form-label">客户姓名</label>
            <div class="layui-input-inline">
              <el-input v-model="regInfo.CHDBUYNAME" :readonly="!isAdd"></el-input>
            </div>
            <label class="layui-form-label" v-if="!isAdd">减免类型</label>
            <div class="layui-input-inline backcolor" v-if="!isAdd">
              <el-select v-model="regInfo.REGISKEYPOINT" @change="getAllCharges">
                <el-option v-for="item in pointType" :key="item.CodeValue" :label="item.CodeName" :value="item.CodeValue">
                </el-option>
              </el-select>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
              <el-input v-model="regInfo.CHDDESC" style="width:740px;"></el-input>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">接尸地点</label>
            <div class="layui-input-inline">
              <el-input v-model="regInfo.REGADDRESS" style="width:740px;" readonly></el-input>
            </div>
          </div>
        </div>
      </div>
      <div :style="{maxHeight:maxHeight+'px'}" style="overflow:auto;">
        <table class="layui-table" style="border-spacing: 0;">
          <colgroup>
            <col>
            <col width="150">
            <col width="150">
            <col>
            <col width="150">
            <col v-if="!isHidden" width="150">
            <col>
            <col v-if="ISSHOWGROUP">
            <col>
          </colgroup>
          <thead>
            <tr>
              <th>项目名称</th>
              <th>单价</th>
              <th>数量</th>
              <th>应收金额</th>
              <th>减免金额</th>
              <th v-if="!isHidden">其他减免</th>
              <th>应缴金额</th>
              <th v-if="ISSHOWGROUP">部门名称</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody ref='inputs'>
            <tr class="allRow" v-for="(chl,index) in chlList">
              <td>
                <el-select @change="chaSelect(index)" ref="select" v-model="chl.CHLCHAID" clearable @keydown.enter.native="enterEvent(index,0)"
                  :filter-method="chaFilter" @visible-change="reset()" filterable>
                  <el-option v-for="item in chaList" :key="item.CHAID" :label="item.CHANAME" :value="item.CHAID" v-show="!disabled(item.CHAID)">
                  </el-option>
                </el-select>
              </td>
              <td>
                <el-input @keyup.native="check(index)" @keydown.enter.native="enterEvent(index,1)" :disabled="chl.CHALOGO === 'A'" v-model="chl.CHLMONEY">
                  <template slot="append">元</template>
                </el-input>
              </td>
              <td>
                <el-input @keyup.native="checknum(index)" @keydown.enter.native="enterEvent(index,2)" v-model="chl.CHLNUM">
                  <template v-if="chl.CHLAUNIT" slot="append">{{chl.CHLAUNIT}}</template>
                </el-input>
              </td>
              <td>
                {{chl.CHLMOUNT}}元
              </td>
              <td>
                <el-input @keyup.native="checks(index)" @input="changeqitamoney(index)" @keydown.enter.native="enterEvent(index,1)" v-model="chl.CHLREDUCTION">
                  <template slot="append">元</template>
                </el-input>
              </td>
              <!-- <td>
                {{chl.CHLREDUCTION}}元
              </td> -->
              <td v-if="!isHidden">
                <el-input @keyup.native="check(index)" @keydown.enter.native="enterEvent(index,3)" v-model="chl.CHLDISCOUNT">
                  <template slot="append">元</template>
                </el-input>
              </td>
              <td>
                {{chl.CHLRECEIVED}}元
              </td>
              <td v-if="ISSHOWGROUP">{{chl.DPTNAME}}</td>
              <td>
                <button class="layui-btn layui-btn-small layui-btn-normal" @click="remove(index)">
                  <i class="layui-icon">&#xe640;</i>
                </button>
              </td>

            </tr>
          </tbody>
          <tfoot>
            <tr>
              <td colspan="2">
                <el-button v-if="isCommon()" type="primary" @click="getCommonItem">添加常用项</el-button>
              </td>
              <td>
                <span>合计</span>
              </td>
              <td>{{ mountTotal }}元</td>
              <td>{{ reductionTotal }}元</td>
              <td v-if="!isHidden">{{ discountTotal }}元</td>
              <td>{{ chlreceivedTotal }}元</td>
              <td v-if="ISSHOWGROUP"></td>
              <td>
                <button class="layui-btn layui-btn-small layui-btn-normal" @click="insert()">
                  <i class="layui-icon">&#xe654;</i>
                </button>
              </td>
            </tr>
          </tfoot>
        </table>
      </div>
      <div class="layui-form-item btnCenter sweet-btn">
        <el-button @click="closeDialog">取消</el-button>
        <el-button type="primary" @click="openDialog()" :loading="this.$store.state.isloading">保存</el-button>
          <div class="layui-inline">
              <el-button type="primary" @click="getHistray">历史记录</el-button>
              <el-dialog title="收费信息" :visible.sync="dialogTableVisible" :modal-append-to-body="false" width="60%">
                 <el-table :data="diechdData" border fit max-height="500" style="width:100%">
                    <el-table-column property="CHLCHANAME" label="收费项目名称" align="center"></el-table-column>
                    <el-table-column property="CHLMONEY" label="单价" align="center"></el-table-column>
                    <el-table-column property="CHLNUM" label="数量" align="center"></el-table-column>
                    <el-table-column property="CHLMOUNT" label="应收金额" align="center"></el-table-column>
                    <el-table-column property="CHLREDUCTION" label="减免金额" align="center"></el-table-column>
                    <el-table-column property="CHLDISCOUNT" label="优惠金额" align="center"></el-table-column>
                    <el-table-column property="CHLRECEIVED" label="实收金额" align="center"></el-table-column>
                    <el-table-column property="CHLPRICE" label="起步价" align="center"></el-table-column>
                    <el-table-column property="CHLHIPRICE" label="最高价" align="center"></el-table-column>
                    <el-table-column property="CHLDESC" label="备注" align="center"></el-table-column>
                </el-table>
                 <span slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="dialogTableVisible = false">取 消</el-button>
                  </span>
              </el-dialog>
          </div>
      </div>
    </sweet-modal>
    <sweet-modal ref="info" class="dialog" :sweetModalMaxWidth="pageWidth">
      <h3>{{title}}</h3>
      <div style="margin:10px 20px">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">逝者姓名</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.REGNAME" readonly></el-input>
            </div>
            <label class="layui-form-label">业务编号</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.REGBUSNUM" readonly></el-input>
            </div>
            <label class="layui-form-label">付款方式</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.CHDCODNAME" readonly></el-input>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">缴款日期</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.CHDDATE" readonly></el-input>
            </div>
            <label class="layui-form-label">缴款时间</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.CHDTIME" readonly></el-input>
            </div>
            <label class="layui-form-label">应收金额</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.CHDAMOUNT" readonly>
                <template slot="append">元</template>
              </el-input>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">减免金额</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.CHDREDUCTION" readonly>
                <template slot="append">元</template>
              </el-input>
            </div>
            <label class="layui-form-label" v-if="!isHidden">其他减免</label>
            <div class="layui-input-inline" v-if="!isHidden">
              <el-input v-model="chdData.CHDDISCOUNT" readonly>
                <template slot="append">元</template>
              </el-input>
            </div>
            <label class="layui-form-label">实收金额</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.CHDRECEIVED" readonly>
                <template slot="append">元</template>
              </el-input>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
              <el-input type="textarea" style="width:740px;" v-model="regInfo.CHDDESC" readonly>
              </el-input>
            </div>
          </div>
        </div>
      </div>
      <div style="maxHeight:500px;overflow:auto;">
        <table class="layui-table" lay-even>
          <colgroup>
            <col>
            <col>
            <col>
            <col>
            <col>
            <col>
            <col>
          </colgroup>
          <thead>
            <tr>
              <th>项目名称</th>
              <th>单价</th>
              <th>数量</th>
              <th>应收金额</th>
              <th>减免金额</th>
              <th v-if="!isHidden">其他减免</th>
              <th v-if="chdData.CHDSTATUS==='B'">实收金额</th>
              <th v-else="chdData.CHDSTATUS==='B'">应缴金额</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="(chl,index) in chlList">
              <td>{{chl.CHLCHANAME}}</td>
              <td>{{chl.CHLMONEY}}元</td>
              <td>{{chl.CHLNUM}}{{chl.CHLAUNIT}}</td>
              <td>{{chl.CHLMOUNT}}元</td>
              <td>{{chl.CHLREDUCTION}}元</td>
              <td v-if="!isHidden">{{chl.CHLDISCOUNT}}元</td>
              <td>{{chl.CHLRECEIVED}}元</td>
            </tr>
          </tbody>
          <tfoot>
            <tr>
              <td colspan="3">合计</td>
              <td>{{ mountTotal }}元</td>
              <td>{{ reductionTotal }}元</td>
              <td v-if="!isHidden">{{ discountTotal }}元</td>
              <td>{{ chlreceivedTotal }}元</td>
            </tr>
          </tfoot>
        </table>
      </div>
      <div class="layui-form-item btnCenter sweet-btn">
        <el-button @click="closeDialog">取消</el-button>
        <!-- <el-button type="primary"  @click="printReduction()" :loading="this.$store.state.isloading">收费清单打印</el-button> -->
        <el-button type="primary" v-if="!iscopysfqd" @click="printReg()" :loading="this.$store.state.isloading">{{printName}}</el-button>
        <el-button type="primary" v-if="(this.chdData.CHDSTATUS == 'B') && iskh && iscopysfqd" @click="printReg()" :loading="this.$store.state.isloading">{{printName}}</el-button>
      </div>
    </sweet-modal>
    <!-- 结账 -->
    <sweet-modal ref="checkout" class="dialog" :sweetModalMaxWidth="pageWidth">
      <h3>{{title}}</h3>
      <div style="margin:10px 20px">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">逝者姓名</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.REGNAME" readonly></el-input>
              <!-- <el-input v-model="chdData.CHDDEADNAME" readonly></el-input> -->
            </div>
            <label class="layui-form-label">客户姓名</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.CHDBUYNAME" readonly></el-input>
            </div>
            <label class="layui-form-label">应收金额</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.CHDAMOUNT" readonly>
                <template slot="append">元</template>
              </el-input>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">减免金额</label>
            <div class="layui-input-inline">
              <el-input v-model="chdData.CHDREDUCTION" readonly>
                <template slot="append">元</template>
              </el-input>
            </div>
            <label class="layui-form-label">应缴金额</label>
            <div class="layui-input-inline">
              <el-input v-model="chlreceivedTotal" readonly>
                <template slot="append">元</template>
              </el-input>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
              <el-input type="textarea" style="width:480px;" v-model="chdData.CHDDESC" readonly>
              </el-input>
            </div>
          </div>
        </div>
      </div>
      <div style="maxHeight:400px;overflow:auto;">
        <table class="layui-table" lay-even>
          <colgroup>
            <col>
            <col>
            <col>
            <col>
            <col>
            <col v-if="!isHidden">
            <col>
          </colgroup>
          <thead>
            <tr>
              <th>项目名称</th>
              <th>单价</th>
              <th>数量</th>
              <th>应收金额</th>
              <th>减免金额</th>
              <th v-if="!isHidden">其他减免</th>
              <th>应缴金额</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="(chl,index) in chlList">
              <td>{{chl.CHLCHANAME}}</td>
              <td>{{chl.CHLMONEY}}元</td>
              <td>{{chl.CHLNUM}}{{chl.CHLAUNIT}}</td>
              <td>{{chl.CHLMOUNT}}元</td>
              <td>{{chl.CHLREDUCTION}}元</td>
              <td v-if="!isHidden">{{chl.CHLDISCOUNT}}元</td>
              <td>{{chl.CHLRECEIVED}}元</td>
            </tr>
          </tbody>
          <tfoot>
            <tr>
              <td colspan="3">合计</td>
              <td>{{ mountTotal }}元</td>
              <td>{{ reductionTotal }}元</td>
              <td v-if="!isHidden">{{ discountTotal }}元</td>
              <td>{{ chlreceivedTotal }}元</td>
            </tr>
          </tfoot>
        </table>
      </div>
      <div style="margin:10px 20px">
        <div class="layui-form-item">
          <div class="layui-inline" style="height:40px;">
            <label class="layui-form-label">付款方式</label>
            <el-radio-group v-model="payData.CHDCODNAME">
              <el-radio-button v-for="item in payment" :key="item.CodeValue" :label="item.CodeValue" class="radio">{{item.CodeName}}</el-radio-button>
            </el-radio-group>
          </div>

          <div class="layui-inline">
            <label class="layui-form-label">结账日期</label>
            <div class="layui-input-inline">
              <el-date-picker v-date type="date" placeholder="选择日期" v-model="CHECKOUTTIME"  format="yyyy-MM-dd"></el-date-picker>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">发票抬头</label>
            <div class="layui-input-inline">
              <el-input v-model="payData.CHDPAYTITLE"></el-input>
            </div>
            <label class="layui-form-label">税号</label>
            <div class="layui-input-inline">
              <el-input v-model="payData.CHDPAYSH"></el-input>
            </div>
          </div>
        </div>
      </div>
      <div class="layui-form-item btnCenter sweet-btn">
        <el-button @click="closeDialog">取消</el-button>
        <el-button type="primary" :loading="this.$store.state.isloading" @click="submit">结账</el-button>
        <el-button v-show="IsShowHangAccount" type="primary" :loading="this.$store.state.isloading" @click="hangAccount">挂账</el-button>
      </div>
    </sweet-modal>
    <sweet-modal ref="print" class="dialog" :sweetModalMaxWidth="pageWidth">
      <h3>{{ printTitle }}</h3>
      <iframe :src="printUrl" style="width:1100px; height:500px;margin-top:20px;"></iframe>
    </sweet-modal>
  </div>
</template>
<style rel="stylesheet/scss" lang="scss" scoped>
  @import "src/styles/common.scss";
  .el-button+.el-button {
    margin-left: 0;
  }

  .sweet-btn {
    margin-top: 20px;
  }
  // .allrow .el-select-dropdown__item.hover, .el-select-dropdown__item:hover{
  //   background-color: red;
  // }
  // .el-select-dropdown__item[data-v-3b50056a]:hover {
  //   background-color: red;
  // }
  .el-select-dropdown__item.hover, .el-select-dropdown__item:hover {
    background-color: yellow;
  }
  // .allrow .el-select-dropdown__item.hover, .el-select-dropdown__item::selection{
  //   background-color: red;
  // }
 
</style>

<script>
  import sweetModal from "@/components/sweetModal";
  import apiBase from "@/api/apiBase.js";
  import { formatDate, timeStringToDate } from "@/utils/date.js";
  import {
    accMul,
    Subtr,
    accAdd
  } from "@/utils/operations.js";
  import {
    ORDER
  } from "@/const/orderConst.js";

  const MANUAL = "A";
  const AUTO = "B";
  const fhMODIFY = "奉化调整收费项目";
  const fhINFO = "奉化详情";
  const fhCHECKOUT = "奉化结账";

  export default {
    name: "hello",
    data() {
      return {
        CHECKOUTTIME:new Date(),
        personality: null,
        pageWidth: 1200,
        maxHeight: 500,
        CHDID: null,
        order: null,
        title: null,
        //所有收费项目
        allCharge: [],
        chaList: [],
        payment: [],
        pointType: [],
        payData: {
          CHDCODNAME:'现金'
        },
        printUrl: null,
        printTitle: null,
        //收费信息
        chdData: {},
        diechdData:[],
        dialogTableVisible:false,
        regInfo: {
          CHDREGNO: null,
          CHDREGID: null,
          REGNAME: null,
          // CHDREGNAME: null,
          CHDDEADNAME: null,
          CHDBUYNAME: null,
          CHDDESC: null,
          REGADDRESS: null,
          REGISKEYPOINT: null,
          REGYITIQX: null,
          REGGHQX: null
        },
        //打印类型
        printName:null,
        //收费项目
        chlList: [],
        chl: {
          CHLID: "",
          CHLCHAID: "", //收费项目ID（必传）
          CHLCHANAME: "", //收费项目名称（必传）
          CHLMOUNT: 0, //应缴金额（必传）
          CHLPRICE: null, //起步价
          CHLHIPRICE: null, //最高价
          CHLMONEY: 0, //单价
          CHLNUM: 1, //数量
          CHLAUNIT: null, //计量单位
          CHLREDUCTION: 0, //减免金额
          CHLDISCOUNT: 0, //优惠金额
          CHLDESC: null, //备注
          CHLRECEIVED: 0,
          CHLFROMLOGO: MANUAL //来源标记
        },
        isshow: null,
        // 是否显示挂账按钮
        IsShowHangAccount: null,
        // 是否把优惠金额改成其他减免
        IsUsePre: null,
        iskh: true,
        iscopysfqd: null,
        ISSHOWGROUP: null,
        isHidden: null,//个性化是否隐藏其他减免
      };
    },
    methods: {
      // 挂账
      hangAccount() {
        this.$confirm("确认是否挂账?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(callback => {
          let data = {
            CHDID: this.CHDID
          };
          apiBase.DoService(data, apiBase.getApiAdress().Checkout.Bill, res => {
            this.$message({
              type: "success",
              message: "挂账成功!"
            });
            this.closeDialog();
            this.refreshData();
            apiBase.DoService(
            data, 
            apiBase.getApiAdress().Pdf.PrintReg,
            res => {
              this.printUrl = res.data.content.PDFNAME;
              this.printTitle = "挂账费用清单打印";
              this.$refs.print.open();
            });
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
      },
      //个性化是否隐藏优惠金额
      getParam() {
        let data = {};
         apiBase.DoService(
          data,
          apiBase.getApiAdress().Param.GetIsHidePreferential,
          res => {
            this.isHidden = res.data.content;
          }
        );
        apiBase.DoService(data, apiBase.getApiAdress().Param.GetIsShowHangAccount, res => {
          this.IsShowHangAccount = res.data.content;
        });
      },
      //获取逝者收费信息
      getHistray(){
        this.dialogTableVisible = true
        if(this.regInfo.CHDREGID == null){
          // console.log('没有编号');
        }else{
          let data = {REGID:this.regInfo.CHDREGID};
          apiBase.DoService(
          data,
          apiBase.getApiAdress().Checkout.GetAllChdByReg,
            res => {
            this.diechdData = res.data.content;
            for(let index in this.diechdData){
              this.diechdData[index].CHLNUM = this.diechdData[index].CHLNUM + this.diechdData[index].CHLAUNIT;
              this.diechdData[index].CHLDISCOUNT = this.diechdData[index].CHLDISCOUNT + '元';
              this.diechdData[index].CHLHIPRICE = this.diechdData[index].CHLHIPRICE + '元';
              this.diechdData[index].CHLMONEY = this.diechdData[index].CHLMONEY + '元';
              this.diechdData[index].CHLMOUNT = this.diechdData[index].CHLMOUNT + '元';
              this.diechdData[index].CHLPRICE = this.diechdData[index].CHLPRICE + '元';
              this.diechdData[index].CHLRECEIVED = this.diechdData[index].CHLRECEIVED + '元';
              this.diechdData[index].CHLREDUCTION = this.diechdData[index].CHLREDUCTION + '元';
            }
           
          }
         )
        }
        
      },
      //获取付款方式
      getPayment() {
        let data = {};
        apiBase.DoService(data, apiBase.getApiAdress().Code.GetPayment, res => {
          this.payment = res.data.content;
        });
      },
      //获取减免类型
      getPointType() {
        let data = {};
        apiBase.DoService(
          data,
          apiBase.getApiAdress().Code.GetKeyPointType,
          res => {
            this.pointType = res.data.content;
          }
        );
      },
      //结账
      chdCheckout() {
        this.payData.CHDID = this.CHDID;
        let data = JSON.parse(JSON.stringify(this.payData));
        data.CHDDATE = formatDate(this.CHECKOUTTIME, "yyyyMMdd");
        apiBase.DoService(data, apiBase.getApiAdress().Checkout.Checkout, res => {
          this.$message({
            type: "success",
            message: "结账成功!"
          });
          if(res.data.msg == '成功'){
            if (this.order === fhCHECKOUT) {
            let data = {};
              apiBase.DoService(
                data, 
                apiBase.getApiAdress().Param.GetCheckoutReport,
                res => {
                  this.personality = res.data.content;
                  if(this.personality == '20'){
                    this.printName = "收费清单打印";
                     this.printReg();//打印
                  }else if(this.personality == '10'){
                    this.printName = "火化登记表打印";
                    this.printReg();//打印
                  }else if(this.personality == '40'){
                    this.printName = "打印火化证明单";
                    this.printReg();//打印
                  }
              });
          }else if(this.order === ORDER.RETCHECKOUT){
            this.printName = "零售清单打印"
            this.printReg();
          }
          
          }
          this.closeDialog();
          this.refreshData();
        },
        res => {
            this.$message.error(res.data.msg);
        });
      },
      //收费项目
      getAllCharge() {
        let data = {
          Data: {
            REGISKEYPOINT: this.regInfo.REGISKEYPOINT
          }
        };
        apiBase.DoService(
          data,
          apiBase.getApiAdress().Checkout.GetAllCharge,
          res => {
            this.allCharge = res.data.content.OutData;
            this.chaList = JSON.parse(JSON.stringify(this.allCharge));
            for (var index in this.chlList) {
              // this.chlCompute(index);
              let chl = this.chlList[index];
              let cha = this.getChaByID(chl.CHLCHAID);
              if (cha) {
                chl.CHLMOUNT = chl.CHLMONEY * chl.CHLNUM; //应收金额
                chl.CHLRECEIVED = chl.CHLMOUNT - chl.CHLREDUCTION - chl.CHLDISCOUNT; //应缴金额
              }
            }
          }
        );
        // this.getCommonItem();
      },
      //计算收费项目
      jisuan() {
        let data = {
          Data: {
            REGISKEYPOINT: this.regInfo.REGISKEYPOINT
          }
        };
        apiBase.DoService(
          data,
          apiBase.getApiAdress().Checkout.GetAllCharge,
          res => {
            this.allCharge = res.data.content.OutData;
            this.chaList = JSON.parse(JSON.stringify(this.allCharge));
            for (var index in this.chlList) {
              this.chlCompute(index);
            }
          }
        );
      },
       //计算当前行CHL
      chlCompute(index) {
        // alert('我计算了！');
        let chl = this.chlList[index];
        let cha = this.getChaByID(chl.CHLCHAID);
        if (cha) {
          chl.CHLMOUNT = chl.CHLMONEY * chl.CHLNUM; //应收金额
          chl.CHLREDUCTION = cha.CHAJMMONEY * chl.CHLNUM; //减免金额
          chl.CHLRECEIVED = chl.CHLMOUNT - chl.CHLREDUCTION - chl.CHLDISCOUNT; //应缴金额
        }
      },
      getAllCharges(){
        // 收费项目
        this.getAllCharge();
        //获取常用项
        this.getCommonItem();
        this.jisuan();
        //把所有的其他减免赋空
        if(false){
          this.jianmianchangezreo();
        }
      },
      jianmianchangezreo(){
        for (let chl of this.chlList){
          chl.CHLDISCOUNT = 0;
        }
      },
      //收费详情
      dataInfo() {
        let data = {
          CHDID: this.CHDID
        };
        apiBase.DoService(data, apiBase.getApiAdress().Checkout.Detail, res => {
          this.chdData = res.data.content;
          let list = res.data.content.List_Chl;

          if(this.chdData.CHDTYPE === "A"){
            this.regInfo.REGNAME = this.chdData.REGNAME;
            this.chdData.REGNAME = this.chdData.REGNAME;
          }else if(this.chdData.CHDTYPE === "B"){
            if(this.chdData.CHDDEADNAME){
              this.regInfo.REGNAME = this.chdData.CHDDEADNAME;
              this.chdData.REGNAME = this.chdData.CHDDEADNAME;
            }else{
              this.regInfo.REGNAME = this.chdData.REGNAME;
              this.chdData.REGNAME = this.chdData.REGNAME;
            }
          };
          this.regInfo.CHDREGNO = this.chdData.REGBUSNUM;
          this.regInfo.CHDBUYNAME = this.chdData.CHDBUYNAME;
          this.regInfo.CHDDESC = this.chdData.CHDDESC;
          this.regInfo.CHDREGID = this.chdData.CHDREGID;

          if (this.regInfo.CHDREGNO) {
            this.getRegAddress();
          }
          this.chlList = this.chdData.List_Chl;
          if (
            this.order !== ORDER.INFO &&
            this.order !== ORDER.CHECKOUT &&
            this.order !== ORDER.RETCHECKOUT
          ) {
            this.insert();
          }
          for (let chl of this.chlList) {
            if (!this.chaList.some(item => {
                return item.CHAID === chl.CHLCHAID;
              }))
              this.chaList.push({
                CHANAME: chl.CHLCHANAME,
                CHAID: chl.CHLCHAID
              });
          }
          this.getAllCharge();
        });
      },
      //修改收费项目
      dataModify(checkout = false) {
        let chlList = JSON.parse(JSON.stringify(this.chlList));
        chlList = chlList.filter(item => {
          return item.CHLCHAID && item.CHLCHAID.length > 0;
        });
        let data = {
          CHDID: this.CHDID,
          CHDREGID: this.regInfo.CHDREGID,
          CHDBUYNAME: this.regInfo.CHDBUYNAME,
          CHDDEADNAME: this.regInfo.REGNAME,
          CHDDESC: this.regInfo.CHDDESC,
          REGISKEYPOINT: this.regInfo.REGISKEYPOINT
        };
      
        for(var i = 0; i < chlList.length; i++){
          for(var s = 0; s < this.chaList.length; s++){
            if(chlList[i].CHLCHAID === this.chaList[s].CHAID){
              chlList[i].CHLCHANAME = this.chaList[s].CHANAME;
            }
          }
        }
        if (chlList.length > 0) {
          data.List_Chl = chlList;
        }
        apiBase.DoService(data, apiBase.getApiAdress().Checkout.Modify, res => {
          this.$message({
            type: "success",
            message: "保存成功!"
          });
          this.closeDialog();
          this.refreshData();
          if (checkout) {
            if (this.order === ORDER.RETMODIFY) {
              this.open(ORDER.RETCHECKOUT, this.CHDID);
            } else {
              this.open(fhCHECKOUT, this.CHDID);
            }
          } else if (this.order === ORDER.CHEMODIFY) {
            this.open(ORDER.INFO, this.CHDID);
          }
        },
        res => {
            this.$message.error(res.data.msg);
        });
      },
      //根据正式业务编号获取地址
      getRegAddress() {
        let data = {
          REGNO: this.regInfo.CHDREGNO
        };
        apiBase.DoService(
          data,
          apiBase.getApiAdress().Registration.GetRegistrationByNo,
          res => {
            let reg = res.data.content;
            this.regInfo.REGADDRESS = reg.REGADDRESS;//地址
            this.regInfo.REGISKEYPOINT = reg.REGISKEYPOINT;
            this.regInfo.REGYITIQX = reg.REGYITIQX;
            this.regInfo.REGGHQX = reg.REGGHQX;
            // this.regInfo.CHDDESC = reg.REGREMARK;
            if(!this.regInfo.CHDDESC){
              this.regInfo.CHDDESC = reg.REGREMARK;
            }
            this.getAllCharge();
          }
        );
      },
      //根据正式业务编号获取ID
      getRegInfo() {
        this.regInfo.CHDDESC = null;
        let data = {
          REGNO: this.regInfo.CHDREGNO
        };
        apiBase.DoService(
          data,
          apiBase.getApiAdress().Registration.GetRegistrationByNo,
          res => {
            let reg = res.data.content;
            if(!reg)
            {
              this.$message({
              type: "error",
              message: "未找到逝者信息!"
              });
              Object.assign(
                this.$data.regInfo,
                this.$options.data().regInfo
                );
              return;
            }
            this.regInfo.CHDREGID = reg.REGID;
            // this.regInfo.CHDREGNAME = reg.REGNAME;
            // this.regInfo.CHDDEADNAME = reg.REGNAME;
            this.regInfo.REGNAME = reg.REGNAME;
            this.regInfo.CHDBUYNAME = reg.REGHANDLERNAME;
            this.regInfo.REGADDRESS = reg.REGADDRESS;
            this.regInfo.REGISKEYPOINT = reg.REGISKEYPOINT;
            // this.regInfo.CHDDESC = reg.REGREMARK;
             if(!this.regInfo.CHDDESC){
              this.regInfo.CHDDESC = reg.REGREMARK;
            }
            this.getAllCharge();//获取收费项目
          }
        );
      },
      //新增零售
      dataAdd(checkout = false) {
        let chlList = JSON.parse(JSON.stringify(this.chlList));
        chlList = chlList.filter(item => {
          return item.CHLCHAID && item.CHLCHAID.length > 0;
        });
        let data = JSON.parse(JSON.stringify(this.regInfo));
        if (chlList.length > 0) {
          data.List_Chl = chlList;
        }
        data.CHDDEADNAME = this.regInfo.REGNAME;
        apiBase.DoService(data, apiBase.getApiAdress().Checkout.Create, res => {
          this.$message({
            type: "success",
            message: "保存成功!"
          });
          this.closeDialog();
          this.refreshData();
          if (checkout) {
            this.open(ORDER.RETCHECKOUT, res.data.content.CHDID);
          }
        },
        res => {
            this.$message.error(res.data.msg);
        });
      },
      printReduction() {
        let data = {
          CHDID: this.CHDID
        };
        apiBase.DoService(
          data,
          apiBase.getApiAdress().Pdf.PrintReduction,
          res => {
            this.printUrl = res.data.content;
            this.printTitle = "减免申请表打印";
            this.$refs.print.open();
          }
        );
      },
      printReg() {
        if(this.printName == "火化登记表打印"){
          let data = {
            CHDID: this.CHDID
          };
          apiBase.DoService(data, apiBase.getApiAdress().Pdf.PrintReg, res => {
            this.printUrl = res.data.content.PDFNAME;
            this.printTitle = "火化登记表打印";
            this.$refs.print.open();
          });
        }else if(this.printName == "零售清单打印"){
          let data = {
            CHDID: this.CHDID
          };
          apiBase.DoService(data, apiBase.getApiAdress().Pdf.PrintRetailchargelist, res => {
            this.printUrl = res.data.content.PDFNAME;
            this.printTitle = "零售清单打印";
            this.$refs.print.open();
          });
        }else if(this.printName == "收费清单打印"){
          let data = {
            CHDID:this.CHDID
          };
          apiBase.DoService(
            data, 
            apiBase.getApiAdress().Pdf.PrintRegList,
            res => {
              this.printUrl = res.data.content.PDFNAME;
              this.printTitle = "收费清单打印";
              this.$refs.print.open();
            });
        }else if(this.printName == "打印火化证明单"){
          let data = {
            REGID:this.regInfo.CHDREGID
          };
          apiBase.DoService(
            data, 
            apiBase.getApiAdress().Pdf.UpdatePrintCre,
            res => {
              this.printUrl = res.data.content.PDFNAME;
              this.printTitle = "打印火化证明单";
              this.$refs.print.open();
            });
        }else{
          console.log('打印出错了');
        }
        
      },
      //新增行
      insert() {
        for (let index in this.chlList) {
          let chl = this.chlList[index];
          if (chl.CHLCHAID.length === 0) {
            this.$message({
              type: "error",
              message: `第${parseInt(index) + 1}行收费项目不能为空!`
            });
            return false;
          }
        }
        this.chlList.push(JSON.parse(JSON.stringify(this.chl)));
        return true;
      },
      remove(index) {
        this.chlList.splice(index, 1);
      },
      //回车事件
      enterEvent(rowNum, colNum) {
        //获取所有行
        let rows = this.$refs.inputs.getElementsByClassName("allRow");
        //获取当前行
        let currow = rows[rowNum];
        // 获取当前行所有列
        let inputs = currow.getElementsByTagName("input");
        //强制隐藏下拉框
        if (colNum === 0) {
          let chl = this.chlList[rowNum];
          if (chl.CHLCHAID.length === 0) {
            this.$message({
              type: "error",
              message: `第${parseInt(rowNum) + 1}行收费项目不能为空!`
            });
            return;
          }
          let select = this.$refs.select;
          select[rowNum].visible = false;
        }
        //最后一列
        if (colNum === inputs.length - 1) {
          //最后一行
          if (rowNum === this.chlList.length - 1) {
            //插入空行
            if (!this.insert()) {
              return;
            }
          }
          //换行
          this.$nextTick(function () {
            this.enterEvent(rowNum + 1, -1);
          });
        } else {
          //获取下一个焦点
          this.$nextTick(function () {
            inputs[colNum + 1].select();
          });
        }
      },
      //禁用已选项
      disabled(chaID) {
        let retVal = this.chlList.some(item => {
          return item.CHLCHAID === chaID;
        });
        return retVal;
      },
      //打开弹出框
      open(order, id) {
        this.getParam();
        this.getPointType();
        this.isshowGroups();
        Object.assign(this.$data, this.$options.data());
        this.CHDID = id;
        this.order = order;
        switch (this.order) {
          case ORDER.ADD:
            this.title = "新增零售";
            this.chlList = [];
            Object.assign(this.$data.regInfo, this.$options.data().regInfo);
            this.getAllCharge();
            this.insert();
            this.$refs.dialog.open();
            break;
          case fhMODIFY:   
          case ORDER.RETMODIFY:
            this.title = "收费项目调整";
            this.dataInfo();
            this.$refs.dialog.open();
            break;
          case ORDER.INFO:
          case fhINFO:
            this.title = "收费详情";
             let data = {};
              apiBase.DoService(
                data, 
                apiBase.getApiAdress().Param.GetCheckoutReport,
                res => {
                  this.personality = res.data.content;
                  if(this.personality == '20'){
                    this.printName = "收费清单打印";
                  }else if(this.personality == '10'){
                    this.printName = "火化登记表打印";
                  }else{
                    this.iskh = false;
                    if(!this.iscopysfqd){this.printName = "收费清单打印";}
                  }
              });
            this.dataInfo();
            this.$refs.info.open();
            break;
          case ORDER.RETAILINFO:
            this.title = "收费详情";
            this.printName = "零售清单打印";
            this.dataInfo();
            this.$refs.info.open();
            break;
          case ORDER.CHECKOUT:
          case ORDER.RETCHECKOUT:
          case fhCHECKOUT:
            this.title = "结账";
            this.getPayment();
            this.dataInfo();
            this.$refs.checkout.open();
            break;
          default:
            break;
        }
      },
      //选择收费项目
      chaSelect(index) {
        let chl = this.chlList[index];
        let cha = this.getChaByID(chl.CHLCHAID);
        //初始化chl
        if (cha) {
          chl.CHALOGO = cha.CHALOGO;
          chl.CHLCHANAME = cha.CHANAME;
          chl.CHLAUNIT = cha.CHAAUNIT;
          chl.CHLMONEY = cha.CHAMONEY;
          chl.CHALOGO = cha.CHALOGO;//控制单价是否能修改
          chl.CHLNUM = 1;
          chl.CHLMOUNT = chl.CHLMONEY * chl.CHLNUM;
          chl.CHLREDUCTION = cha.CHAJMMONEY * chl.CHLNUM;
          chl.CHLDISCOUNT = cha.CHADISCOUNT * chl.CHLNUM;
          chl.CHLRECEIVED = chl.CHLMOUNT - chl.CHLREDUCTION - chl.CHLDISCOUNT;
          // chl.CHALOGO = "B";
          
        }
      },
      reset() {
        this.chaList = JSON.parse(JSON.stringify(this.allCharge));
      },
      //获取常用项
      getCommonItem() {
        let data = {
          Data: {
            "REGYITIQX": this.regInfo.REGYITIQX,
            "REGGHQX": this.regInfo.REGGHQX
          }
        };
        apiBase.DoService(data, apiBase.getApiAdress().CommonItem.Query, res => {
          let common = res.data.content.OutData;
          common.forEach(item => {
            var isContain = this.chlList.some(chl => {
              return item.CNOCHAID === chl.CHLCHAID;
            });
            if (!isContain) {
              let chl = JSON.parse(JSON.stringify(this.chl));
              let cha = this.getChaByID(item.CNOCHAID);
              if (cha) {
                chl.CHALOGO = cha.CHALOGO;
                chl.CHLCHAID = cha.CHAID;
                chl.CHLCHANAME = cha.CHANAME;
                chl.CHLAUNIT = cha.CHAAUNIT;
                chl.CHLMONEY = cha.CHAMONEY;
                chl.CHLNUM = 1;
                chl.CHLMOUNT = chl.CHLMONEY * chl.CHLNUM;
                chl.CHLREDUCTION = cha.CHAJMMONEY * chl.CHLNUM;
                chl.CHLDISCOUNT = cha.CHADISCOUNT * chl.CHLNUM;
                chl.CHLRECEIVED =
                  chl.CHLMOUNT - chl.CHLREDUCTION - chl.CHLDISCOUNT;
              }
              this.chlList.push(chl);
            }
          });
          this.chlList = this.chlList.filter(item => {
            return item.CHLCHAID && item.CHLCHAID.length > 0;
          });
          this.chlList.push(JSON.parse(JSON.stringify(this.chl)));
        });
      },
      //ID获取收费项目
      getChaByID(chaId) {
        for (var i in this.allCharge) {
          var cha = this.allCharge[i];
          if (cha.CHAID === chaId) {
            return cha;
          }
        }
      },
      check(index) {
        let chl = this.chlList[index];
        chl.CHLMONEY = this.checkMoney(chl.CHLMONEY.toString());
        chl.CHLDISCOUNT = this.checkMoney(chl.CHLDISCOUNT.toString());
      },
      // 专属于数量的修改事项
      checknum(index){
        let chl = this.chlList[index];
        chl.CHLDISCOUNT = 0;
        chl.CHLNUM = this.checkNumber(chl.CHLNUM.toString());
        let cha = this.getChaByID(chl.CHLCHAID);
        if (cha) {

          //减免单价大于单价，减免单价取单价
          //该部分是获取减免单价的 CHAJMMONEY
          var CHAJMMONEY = cha.CHAJMMONEY;
          if (chl.CHLMONEY < cha.CHAJMMONEY) {
            CHAJMMONEY = chl.CHLMONEY; //获取减免单价
          }

          //减免金额大于减免限价，减免金额取限价
          var CHLREDUCTION = accMul(CHAJMMONEY, chl.CHLNUM); //算出减免金额
          if (cha.CHAJMHIMONEY !== 0 && CHLREDUCTION > cha.CHAJMHIMONEY) {
            chl.CHLREDUCTION = cha.CHAJMHIMONEY;
          } else {
            chl.CHLREDUCTION = CHLREDUCTION;
          }

        }
      },
      // 专属于减免金额的修改事项
      checks(index){
        let chl = this.chlList[index];
        chl.CHLDISCOUNT = 0;
        chl.CHLREDUCTION = this.checkMoney(chl.CHLREDUCTION.toString());
        let cha = this.getChaByID(chl.CHLCHAID);
        if (cha) {

          //减免单价大于单价，减免单价取单价
          //该部分是获取减免单价的 CHAJMMONEY
          var CHAJMMONEY = cha.CHAJMMONEY;
          if (chl.CHLMONEY < cha.CHAJMMONEY) {
            CHAJMMONEY = chl.CHLMONEY; //获取减免单价
          }

          //减免金额大于减免限价，减免金额取限价
          // var CHLREDUCTION = accMul(CHAJMMONEY, chl.CHLNUM); //算出减免金额
          if (cha.CHAJMHIMONEY !== 0 && chl.CHLREDUCTION > cha.CHAJMHIMONEY) {
            chl.CHLREDUCTION = cha.CHAJMHIMONEY;
          } else {
            // alert(chl.CHLMOUNT);
            if(chl.CHLREDUCTION > chl.CHLMOUNT){
              chl.CHLREDUCTION = chl.CHLMOUNT;
            }else{
              chl.CHLREDUCTION = chl.CHLREDUCTION;
            }
          }
        }
      },
      // 减免金额改变，其他减免清零
      changeqitamoney(index){
        let chl = this.chlList[index];
        chl.CHLDISCOUNT = 0;
      },
      isCommon() {
        return this.order === fhMODIFY;
      },
      //只能输入正整数
      checkNumber(value) {
        value = value.replace(/\D/g, "").replace(/^0+(?=\d)/, "");
        if (value !== "") {
          if (value.substr(0, 1) === "0" && value.length === 2) {
            value = value.substr(1, value.length);
          }
        } else {
          value = 0;
        }
        return value;
      },
      //只能输入金额
      checkMoney(value) {
        //修复第一个字符是小数点 的情况.
        if (value !== "" && value.substr(0, 1) === ".") {
          value = "";
        }
        value = value.replace(/^0*(0\.|[1-9])/, "$1"); //解决 粘贴不生效
        value = value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
        value = value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
        value = value
          .replace(".", "$#$")
          .replace(/\./g, "")
          .replace("$#$", ".");
        value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3"); //只能输入两个小数
        if (value.indexOf(".") < 0 && value !== "") {
          //以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
          if (value.substr(0, 1) === "0" && value.length === 2) {
            value = value.substr(1, value.length);
          }
        } else if (value === "") {
          value = 0;
        }
        return value;
      },
      //自定义筛选
      chaFilter(val) {
        this.chaList = JSON.parse(JSON.stringify(this.allCharge));
        if (val) {
          if (val.length > 0)
            this.chaList = this.allCharge.filter(item => {
              return (
                item.CHANAME.indexOf(val) > -1 ||
                item.CHADM.toLowerCase().indexOf(val.toLowerCase()) > -1
              );
            });
        }
      },
      //提交
      submit(checkout = false) {
        switch (this.order) {
          case ORDER.ADD://新增
            this.dataAdd(checkout);
            break;
          case ORDER.CHEMODIFY://收费项目调整
          case ORDER.RETMODIFY://零售项目调整
          case fhMODIFY:
            this.dataModify(checkout);
            break;
          case ORDER.CHECKOUT://结账
          case ORDER.RETCHECKOUT://零售结账
          case fhCHECKOUT:
            this.chdCheckout();
            break;
          default:
            break;
        }
      },
      closeDialog() {
        switch (this.order) {
          case ORDER.ADD:
          case ORDER.CHEMODIFY:
          case ORDER.RETMODIFY:
          case fhMODIFY:
            this.$refs.dialog.close();
            break;
          case ORDER.CHECKOUT:
          case ORDER.RETCHECKOUT:
          case fhCHECKOUT:
            this.$refs.checkout.close();
            break;
          case ORDER.INFO:
            this.$refs.info.close();
            break;
          case ORDER.RETAILINFO:
            this.$refs.info.close();
            break;
          default:
            break;
        }
      },
     
      refreshData() {
        this.$emit("refreshData");
      },
      openDialog() {
        if(this.isShow === 1){
            this.submit(false);
        }else if(this.isShow === 0){
          this.$confirm("是否直接进行结账?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          })
          .then(() => {
            this.submit(true);
          })
          .catch(() => {
            this.submit(false);
          });
        }
      },
      isshowGroups(){
        let data = {};
        apiBase.DoService(data, apiBase.getApiAdress().Param.GetIsShowDptname, res => {
          this.ISSHOWGROUP = res.data.content;
        });
      }
    },
    created() {
       let data = {};
        apiBase.DoService(data, apiBase.getApiAdress().Param.GetIsDirectAccount, res => {
          this.isShow = res.data.content;
        });
        apiBase.DoService(data, apiBase.getApiAdress().Param.GetIsUsePre, res => {
          this.IsUsePre = res.data.content;
        });
        apiBase.DoService({},apiBase.getApiAdress().Param.GetNoconditionPrint,res => {
          this.iscopysfqd = res.data.content; 
        });
    },
    //计算属性
    computed: {
      mountTotal() {
        let total = 0;
        for (let chl of this.chlList) {
          total = accAdd(total, chl.CHLMOUNT);
        }
        return total;
      },
      reductionTotal() {
        let total = 0;
        for (let chl of this.chlList) {
          total = accAdd(total, chl.CHLREDUCTION);
        }
        return total;
      },
      discountTotal() {
        let total = 0;
        for (let chl of this.chlList) {
          total = accAdd(total, chl.CHLDISCOUNT);
        }
        return total;
      },
      chlreceivedTotal() {
        let total = 0;
        for (let chl of this.chlList) {
          total = accAdd(total, chl.CHLRECEIVED);
        }
        return total;
      },
      isAdd() {
        return this.order === ORDER.ADD || this.order === ORDER.RETMODIFY;
      },
    },
    
     watch: {
      chlList: {
        handler(newValue, oldValue) {
          for (let chl of this.chlList) {
            let cha = this.getChaByID(chl.CHLCHAID);
            if (cha) {
              // chl.CHLNUM 数量 chl.CHLMONEY 单价
              chl.CHLMOUNT = accMul(chl.CHLMONEY, chl.CHLNUM); //算出应收金额

              var CHLJMH = Subtr(chl.CHLMOUNT, chl.CHLREDUCTION); //应收金额 - 减免金额 = 应缴金额
              if(chl.CHLDISCOUNT > CHLJMH){
                chl.CHLDISCOUNT = CHLJMH
              };
              chl.CHLRECEIVED = CHLJMH - chl.CHLDISCOUNT;
            }
          }
        },
        deep: true
      },
    },
    mounted() {
      apiBase.DoService(
      {},
      apiBase.getApiAdress().Param.GetBackgroundColor,
      res => {
        let backcolor = '';
        if(res.data.content === '20'){
          const inputs = document.querySelectorAll('.backcolor input.el-input__inner');
          backcolor = 'rgb(255,255,153)'
          for(var i = 0; i< inputs.length; i++){
          inputs[i].style.backgroundColor = backcolor
          }
        }
      }
    );
    },
    components: {
      sweetModal
    }
  };

</script>
